package com.xunlai.infra.permission.storage.entity;

import lombok.*;
import org.springframework.data.annotation.Id;
import org.springframework.data.relational.core.mapping.Table;

import java.io.Serial;
import java.io.Serializable;

/**
 * @author liang
 * @date 2022/11/30 14:49
 */
@Table("system_role_relation")
@Data
@EqualsAndHashCode(callSuper = false)
@NoArgsConstructor
@AllArgsConstructor
@Builder
public class RoleRelation extends BaseEntity implements Serializable {

    @Serial
    private static final long serialVersionUID = 5202796596521304700L;

    @Id
    private Long id;

    /**
     * 角色ID
     */
    private Long roleId;

    /**
     * 角色code
     */
    private String roleCode;

    /**
     * 关联对象id
     */
    private Long targetId;

    /**
     * 关联对象类型
     */
    private Short targetType;


    public enum RelationTargetTypeEnum{
        USER((short) 1,"用户"),
        AUTH_GROUP((short) 2,"自定义组"),
        DEPARTMENT((short)3,"部门"),
        POSITION((short)4,"职位")
        ;
        private final short type;

        private final String desc;

        RelationTargetTypeEnum(short type, String desc) {
            this.type = type;
            this.desc = desc;
        }

        public short getType() {
            return type;
        }

        public String getDesc() {
            return desc;
        }
    }
}
